<body>
<div class="topbar">
	<div class="content">
    	<div class="left">
        	<!--BEGIN: Topbar Left-->
            <div class="widget-message">
            	<a href="#" title="">
                	Tin nhắn mới
                    <span>5</span>
                </a>
            </div>
            <!--END Topbar Left-->
        </div>
        <div class="right">
        	<!--BEGIN: Topbar Right-->
            
            <script type="text/javascript">
                function logOut(){
                    var result = confirm("Bạn có chắc chắn muốn đăng xuất không?");
                    return result;
                }
                           
            </script>
            <div class="widget-logout">
            	<a href="logout.php" title="" onclick="return logOut();">
                	<span>Thoát</span>
                </a>
            </div>
            <!--END Topbar Right-->
        </div>
        <div class="clear"></div>
    </div>
</div>
<div class="header">
	<div class="content">
        <div class="right">
        	<!--BEGIN: Header Right-->
            <div class="widget-menu tab">
            	<ul>
                	<li class="first">
                    	<a href="#" class="active" title="">
                        	<span>
                            	<img src="file:///G:/Download/GEATE/icon_16x16.png" alt="" />
                                Trang chủ
                            </span>
                        </a>
                    </li>
                    <li>
                    	<a href="#" title="">
                        	<span>
                            	<img src="file:///G:/Download/GEATE/icon_16x16.png" alt="" />
                                Hỗ trợ
                            </span>
                        </a>
                    </li>
                    <li>
                    	<a href="#" title="">
                        	<span>
                            	<img src="file:///G:/Download/GEATE/icon_16x16.png" alt="" />
                                Mã nguồn
                            </span>
                        </a>
                    </li>
                    <div class="clear"></div>
                </ul>
            </div>
            <!--END Header Right-->
        </div>
        <div class="clear"></div>
    </div>
</div>
<div class="menu">
	<div class="content">
    	<!--BEGIN: Menu-->
        <div class="widget-menu list">
        	<ul id="nav">
            	<li>
                	<a href="index.php" class="active" title="">Quản lý đơn hàng</a>
                </li>
                <li>
                	<a href="books.php" title="">Quản lý sách</a>
                    <ul>
                        <li>
                            <a href="addbook.php" title="">Thêm sách</a>
                        </li>
                    </ul>
                </li>
                <li>
                	<a href="accounts.php" title="">Quản lý tài khoản</a>
                    <ul>
                        <li>
                            <a href="addmember.php" title="">Thêm tài khoản</a>
                        </li>
                    </ul>
                </li>
                <div class="clear"></div>
            </ul>
        </div>
        <!--END Menu-->
    </div>
</div>
<div class="main">
	<div class="content">
    	<div class="toolbar">
        	<!--BEGIN: Toolbar-->
            <div class="widget-toolbar">
            	<h2 class="list">Chi tiết đơn hàng</h2>
                <div class="clear"></div>
            </div>
            <!--END Toolbar-->
        </div>
        <div class="body">
        	<!--BEGIN: Body-->
            <div class="module-list">
                <div class="clear"></div>
                <table cellpadding="0" cellspacing="0">
                	<tr>
                        <th width="80">Ngày đặt hàng</th>                                             
                        <th width="80">Họ tên</th>
                        <th width="80">Địa chỉ</th>
                        <th width="80">Số điện thoại</th>           
                        <th width="80">Tên sách</th> 
                        <th width="80">Giá tiền</th> 
                        <th width="80">Số lượng</th> 
                        <th width="50">Tổng tiền</th>
                        <th width="100">Phương thức thanh toán</th>
                    </tr>
                    <?php 
                    $count = count($orderDetailList);
                    //Nếu có đơn hàng
                    if($count > 0)
                    {
                        $totalPrice = 0;//Tổng số tiền của tất cả các cuốn sách trong đơn hàng
                        foreach($orderDetailList as $orderDetail)
                        {
                            if($orderDetail["SaleOffPrice"] > 0)
                            {
                                $totalPrice += $orderDetail["Quantity"] * $orderDetail["SaleOffPrice"];
                            }
                            else
                            {
                                $totalPrice += $orderDetail["Quantity"] * $orderDetail["Price"];
                            }  
                        }
                        
                        $price = 0;
                        if($orderDetailList[0]["SaleOffPrice"] > 0)
                        {
                            $price = $orderDetailList[0]["Quantity"] * $orderDetailList[0]["SaleOffPrice"];
                        }
                        else
                        {
                            $price = $orderDetailList[0]["Quantity"] * $orderDetailList[0]["Price"];
                        } 
                        
                        $code = "<tr>
                                    <td align='center' rowspan='$count'>" . $orderDetailList[0]["OrderDate"] . "</td>
                                    <td align='center' rowspan='$count'>" . $orderDetailList[0]["Fullname"] . "</td>
                                    <td align='center' rowspan='$count'>" . $orderDetailList[0]["Address"] . "</td>
                                    <td align='center' rowspan='$count'>" . $orderDetailList[0]["Phone"] . "</td>
                                    <td align='center'>" . $orderDetailList[0]["Name"] . "</td>
                                    <td align='center'>" . $price . "</td>
                                    <td align='center'>" . $orderDetailList[0]["Quantity"] . "</td>
                                    <td align='center' rowspan='$count'>" . $totalPrice . "</td>
                                    <td align='center' rowspan='$count'>" . $orderDetailList[0]["Payment"] . "</td>
                                 </tr>";
                                 
                        
                        for($i=1; $i<$count; $i++)
                        {   
                            if($orderDetailList[$i]["SaleOffPrice"] > 0)
                            {
                                $price = $orderDetailList[$i]["Quantity"] * $orderDetailList[$i]["SaleOffPrice"];
                            }
                            else
                            {
                                $price = $orderDetailList[$i]["Quantity"] * $orderDetailList[$i]["Price"];
                            }         
                            $code .= "<tr>
                                        <td align='center'>" . $orderDetailList[$i]["Name"] . "</td>
                                        <td align='center'>" . $price . "</td>
                                        <td align='center'>" . $orderDetailList[$i]["Quantity"] . "</td>
                                      </tr>";
                                           
                        }
                        
                        echo $code;                         
                    }
                    ?>
                </table>
                <div class="pagination">
                	<div>
                    	<a href="#">Đầu</a>
                        <a href="#">Lùi</a>
                        <a href="#">1</a>
                        <span>2</span>
                        <a href="#">3</a>
                        <a href="#">4</a>
                        <a href="#">Tới</a>
                        <a href="#">Cuối</a>
                    </div>
                </div>
            </div>
            
            <!--END Body-->
        </div>
        <div class="clear"></div>
    </div>
</div>
<div class="footer">
	<div class="content">
    	<div class="left">
        	<!--BEGIN: Footer Left-->
            <!--END Footer Left-->
        </div>
        <div class="right">
        	<!--BEGIN: Footer Right-->
            <!--END Footer Right-->
        </div>
        <div class="clear"></div>
    </div>
</div>
</body>
</html>